<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <title>订单列表</title>
    <link rel="stylesheet" href="/css/style.css">
</head>
<body>
    <!-- 导航栏 -->
    <div style="width:100%;background:#fff;box-shadow:0 2px 5px rgba(0,0,0,0.05);padding:16px 0 8px 0;display:flex;justify-content:flex-end;align-items:center;position:sticky;top:0;z-index:10;">
        <a href="/admin/stock-warning" class="order-btn" style="margin-right:40px;width:auto;padding:6px 18px;background:#ff9800;">后台管理</a>
        <a href="/dishes" class="order-btn" style="margin-right:40px;width:auto;padding:6px 18px;">返回菜单</a>
        <a href="/logout" class="order-btn" style="margin-right:40px;width:auto;padding:6px 18px;background:#e44d26;">退出登录</a>
    </div>
    <div class="container">
        <h1>订单列表</h1>
        <table style="width:100%;background:white;border-radius:8px;box-shadow:0 2px 5px rgba(0,0,0,0.1);">
            <thead>
            <tr>
                <th>订单编号</th>
                <th>菜品</th>
                <th>数量</th>
                <th>总价</th>
                <th>下单时间</th>
                <th>姓名</th>
                <th>电话</th>
                <th>地址</th>
                <th>支付方式</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <c:forEach items="${orders}" var="order">
                <tr>
                    <td>${order.id}</td>
                    <td>${order.dish.name}</td>
                    <td>${order.quantity}</td>
                    <td>￥${order.totalPrice}</td>
                    <td>${order.orderTime}</td>
                    <td>${order.customerName}</td>
                    <td>${order.customerPhone}</td>
                    <td>${order.address}</td>
                    <td>${order.description}</td>
                    <td style="vertical-align: middle;">
                        <div style="display: flex; align-items: center; gap: 8px;">
                            <a href="/comments/order/${order.id}" class="order-btn" style="padding:4px 10px;width:auto;">评价</a>
                            <form action="/orders/${order.id}/status" method="post" style="display:flex;align-items:center;gap:4px;margin:0;">
                                <select name="status" style="height:32px;">
                                    <option value="PENDING" ${order.status == 'PENDING' ? 'selected' : ''}>待处理</option>
                                    <option value="CONFIRMED" ${order.status == 'CONFIRMED' ? 'selected' : ''}>已确认</option>
                                    <option value="DELIVERING" ${order.status == 'DELIVERING' ? 'selected' : ''}>配送中</option>
                                    <option value="COMPLETED" ${order.status == 'COMPLETED' ? 'selected' : ''}>已完成</option>
                                    <option value="CANCELLED" ${order.status == 'CANCELLED' ? 'selected' : ''}>已取消</option>
                                    <option value="PAID" ${order.status == 'PAID' ? 'selected' : ''}>已支付</option>
                                </select>
                                <button type="submit" class="order-btn" style="padding:4px 10px;width:auto;">更新</button>
                            </form>
                        </div>
                    </td>
                </tr>
            </c:forEach>
            </tbody>
        </table>
        <div style="margin-top:20px;text-align:center;">
            <a href="/dishes" class="order-btn">返回菜单</a>
        </div>
    </div>
</body>
</html> 